Back to Article
Starwars Characters
Download Source

Starwars Characters

Author

John Little

In [1]:
library(tidyverse)
Warning: package 'tidyr' was built under R version 4.3.2
Warning: package 'readr' was built under R version 4.3.2
Warning: package 'dplyr' was built under R version 4.3.2
Warning: package 'stringr' was built under R version 4.3.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Import data

In [2]:
# for example
# dining_df <- read_csv("brodhead_center.csv")

# but we'll use dplyr::starwars

data(starwars)

Create spatial plot:

In [3]:
#|   in the _Star Wars_ franchise."

starwars |> 
  filter(mass < 500) |> 
  drop_na(mass) |> 
  ggplot(aes(height, mass)) +
  geom_smooth(method = lm, se = FALSE, color = "grey80") +
  geom_jitter(aes(color = gender)) +
  scale_color_brewer(palette = "Set1",
                     na.value = "goldenrod") +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'
A scatterplot of mass over height for select characters in the _Star Wars_ franchise.
Starwars characters: mass over height